Skip to content

Conversation

@Akshaychdev
Copy link

Fix dark mode toggle visibility and system theme handling (Redmine 6.1.0)

Summary

This PR fixes two issues affecting the Dark Mode plugin in Redmine 6.1.0:

  • Restores visibility of the dark mode toggle in the account menu
  • Prevents automatic dark mode from overriding explicit user preference

Details

  • The dark mode toggle is now inserted as a proper <li> within the account menu, ensuring it is visible and styled correctly in Redmine 6.1.0.
  • Automatic dark mode based on prefers-color-scheme is now optional and controlled via a plugin setting.
  • By default, dark mode activates only through the manual toggle. When enabled by an admin, browser/OS theme preference is respected.
image image

Configuration

A new plugin setting has been added:

Administration → Plugins → Dark Mode → Configure
Follow browser/OS dark theme preference (default: disabled)

image

Changes

  • assets/javascripts/dark.js – Fix toggle insertion into account menu
  • assets/stylesheets/dark.css – Apply system theme conditionally
  • lib/dark_application_hooks.rb – Add body class based on setting
  • init.rb – Register plugin settings
  • app/views/settings/_redmine_dark_settings.html.erb – Settings UI
  • config/settings.yml – Settings configuration

Testing

  • Verified locally using Redmine 6.1.0 Docker setup
  • Toggle is visible and functional
  • Manual toggle persists via cookie
  • Automatic dark mode applies only when explicitly enabled
  • Manual toggle always overrides system preference

Notes

I am not a Ruby specialist; the Ruby changes were implemented with AI assistance and validated through local testing. Feedback and improvements are welcome.

Compatibility

  • ✅ Redmine 6.1.0
  • ✅ Backward compatible with earlier versions

…ting for Redmine 6.1.0

- Insert dark mode toggle as a proper <li> inside the account menu to ensure visibility in Redmine 6.1.0
- Apply system/browser dark theme only when explicitly enabled via plugin settings
@IliaLenskii
Copy link
Contributor

It's just a dark theme.
This means that making edits to "rb" and "xml" is a bad idea.

@IliaLenskii
Copy link
Contributor

I think that it is not necessary to make edits to the rb and xml files.

@fraoustin What do you think?

@Akshaychdev
Copy link
Author

Yeah, I also felt this might be a bit of overkill, since it’s basically a theme toggle wrapped as a plugin for the switching button.

That said, I use dark mode at the browser level, and this plugin is designed to always follow the browser preference. Because of that, turning dark mode off in the app didn’t really work - the plugin would just turn it back on based on the browser setting.

So I was left with two choices:

  • Either remove the browser-preference behavior completely, or
  • Add a toggle so users can decide whether they want the plugin to respect the browser setting.

I went with the second option since it keeps the original behavior intact while still giving users control when they need it.

Check if this aligns with your vision - if not, no worries at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants